# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=aws-c-cal
pkgver=0.8.0
pkgrel=0
pkgdesc="AWS Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives"
url="https://github.com/awslabs/aws-c-cal"
# s390x: aws-c-common
arch="all !s390x"
license="Apache-2.0"
makedepends="
	aws-c-common-dev
	cmake
	openssl-dev
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-cal/archive/refs/tags/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# just test binaries
	# shellcheck disable=2115
	rm -rf "$pkgdir"/usr/bin/
}

dev() {
	default_dev
	amove usr/lib/aws-c-cal
}

sha512sums="
d0d1bab35dc1bd153276eaa973b8f739e1ea7e9822a6c335af54651e3e3b9cd11acf5b4ac77a7087dace69fe89a92261ef510390cb23b2a96f87ba6cf78bbd01  aws-c-cal-0.8.0.tar.gz
"
